package com.heima.article.task;

import com.heima.article.service.IHotArticleService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 定时任务：计算最近5天发布文章的得分，将文章缓存到redis中
 */
@Slf4j
@Component
public class RecentHotArticle {

    @Autowired
    private IHotArticleService hotArticleService;


    /**
     * 定时计算最近5天发布所有文章得分，将得分较高存入redis缓存
     * @return
     */
    @XxlJob("computeHotArticleJob")
    private ReturnT<String> computeHotArticleJob(){
        log.info("定时计算热点文章");
        hotArticleService.compute();
        return ReturnT.SUCCESS;
    }

}
